package netWork;
import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25397
 * Date: 2022-04-17
 * Time: 17:48
 */
public class TcpDictServer extends TcpThreadPoolEchoServer{

    private HashMap<String,String> dict=new HashMap<>();

    public TcpDictServer(int port) throws IOException {
        super(port);
        dict.put("cat","猫");
        dict.put("dog","狗");
        dict.put("pig","猪");
    }


    public String process(String request){
        return dict.getOrDefault(request,"该词无法被翻译");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer server=new TcpDictServer(1000);
        server.start();
    }
}
